package com.practices.activity;

import java.io.InputStream;

import com.practice.R;
import com.practices.util.FileUtil;
import com.practices.util.HttpUtil;
import com.practices.util.Util;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class DownPicActiviy extends Activity{
	private Button btn_down;
	private String url="http://upupyoyoyo.net/COFFdD0xMzY3NDk1NTY0Jmk9MjE4LjE3LjE2Mi4xMzMmdT1Tb25ncy92MS9mYWludFFDLzEwL2I2YjVkNGQ3NDdmNWFhYTNlNWMyMTE1ZTM4MGNkNzEwLm1wMyZtPTE2OGFmODI3ZjA1NGUxZDNhY2JiNmYyZTIxMjZlMzcwJnY9ZG93biZuPbfF0MSyu8/CJnM9u8bQoef6JnA9cw==.mp3";
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.downpic_activity);
		initView();
	}
	private void initView() {
		btn_down=(Button) findViewById(R.id.btn_downmp3);
		btn_down.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Util.showProgressDialogstyleStyle_spinner(DownPicActiviy.this, "loading...");
				new Thread(new Runnable() {
					@Override
					public void run() {
						DownFile(url);
					}
				}).start();
				Util.dismissProgressDialog();
			}
		});
	}
	
	
	private void DownFile(String url) {
		byte[] buf=HttpUtil.getDataForIObytes(url);
		FileUtil.saveFile(FileUtil.root_path+"abc.mp3", buf);
	}
}
